package com.d3works.apps.supplychain.service;

import com.d3works.apps.base.db.Batch;
import com.d3works.apps.base.db.Product;
import com.d3works.apps.base.db.Unit;
import com.d3works.apps.purchase.db.PurchaseOrderLine;
import com.d3works.apps.sale.db.SaleOrderLine;
import com.d3works.apps.stock.db.StockMove;
import com.d3works.apps.stock.db.StockMoveLine;
import com.d3works.exception.D3worksException;
import java.math.BigDecimal;
import java.util.List;

public interface StockMoveLineServiceSupplychain {

  /**
   * Compared to the method in module stock, it adds the requested reserved qty. Allows to create
   * stock move from supplychain module with requested reserved qty. We also add sale order line and
   * purchase order line to create the link.
   *
   * @param product
   * @param productName
   * @param description
   * @param quantity
   * @param requestedReservedQty
   * @param unitPrice
   * @param purchasePrice
   * @param unit
   * @param stockMove
   * @param type
   * @param taxed
   * @param taxRate
   * @param saleOrderLine
   * @param purchaseOrderLine
   * @return the created stock move line.
   * @throws D3worksException
   */
  public StockMoveLine createStockMoveLine(
      Product product,
      String productName,
      String description,
      BigDecimal quantity,
      BigDecimal requestedReservedQty,
      BigDecimal unitPrice,
      BigDecimal companyUnitPriceUntaxed,
      BigDecimal purchasePrice,
      Unit unit,
      StockMove stockMove,
      int type,
      boolean taxed,
      BigDecimal taxRate,
      SaleOrderLine saleOrderLine,
      PurchaseOrderLine purchaseOrderLine)
      throws D3worksException;

  /**
   * Get a merged stock move line.
   *
   * @param stockMoveLineList
   * @return
   * @throws D3worksException
   */
  StockMoveLine getMergedStockMoveLine(List<StockMoveLine> stockMoveLineList)
      throws D3worksException;

  boolean isAvailableProduct(StockMove stockMove, StockMoveLine stockMoveLine);

  void setInvoiceStatus(StockMoveLine stockMoveLine);

  public boolean isAllocatedStockMoveLine(StockMoveLine stockMoveLine);

  BigDecimal getAmountNotInvoiced(
      StockMoveLine stockMoveLine, boolean isPurchase, boolean ati, boolean recoveredTax)
      throws D3worksException;

  BigDecimal getAmountNotInvoiced(
      StockMoveLine stockMoveLine,
      PurchaseOrderLine purchaseOrderLine,
      SaleOrderLine saleOrderLine,
      boolean isPurchase,
      boolean ati,
      boolean recoveredTax)
      throws D3worksException;

  Batch validateCutOffBatch(List<Long> recordIdList, Long batchId) throws D3worksException;
}
